Bug 498010, 546005 - fix assertion in gtk_tree_view_set_cursor_on_cell
authorKristian Rietveld <kris@gtk.org>
Thu, 30 Jul 2009 11:58:25 +0000 (13:58 +0200)
committerKristian Rietveld <kris@gtk.org>
Thu, 30 Jul 2009 18:24:31 +0000 (20:24 +0200)
Instead of failing with warning on !tree_view->priv->tree, return
silently when tree_view->priv->model is NULL.  Clarified in the
documentation that for invalid paths (and every path is invalid when no
model is set), the function will fail silently although the current
cursor will be unset.

Fixes bugs 498010 and 546005.

gtk/gtktreeview.c

index eaf088d70e0df12888cc89083b4118ff52112830..b7a0a7e283bae2a6586606c4dce085fa68ec095b 100644 (file)
@@ -12517,6 +12517,9 @@ gtk_tree_view_get_cursor (GtkTreeView        *tree_view,
  * This function is often followed by @gtk_widget_grab_focus (@tree_view) 
  * in order to give keyboard focus to the widget.  Please note that editing 
  * can only happen when the widget is realized.
+ *
+ * If @path is invalid for @model, the current cursor (if any) will be unset
+ * and the function will return without failing.
  **/
 void
 gtk_tree_view_set_cursor (GtkTreeView       *tree_view,
@@ -12548,6 +12551,9 @@ gtk_tree_view_set_cursor (GtkTreeView       *tree_view,
  * widget.  Please note that editing can only happen when the widget is
  * realized.
  *
+ * If @path is invalid for @model, the current cursor (if any) will be unset
+ * and the function will return without failing.
+ *
  * Since: 2.2
  **/
 void
@@ -12558,9 +12564,12 @@ gtk_tree_view_set_cursor_on_cell (GtkTreeView       *tree_view,
                                  gboolean           start_editing)
 {
   g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
-  g_return_if_fail (tree_view->priv->tree != NULL);
   g_return_if_fail (path != NULL);
   g_return_if_fail (focus_column == NULL || GTK_IS_TREE_VIEW_COLUMN (focus_column));
+
+  if (!tree_view->priv->model)
+    return;
+
   if (focus_cell)
     {
       g_return_if_fail (focus_column);